<style type="text/css">
.normal_form[form-role="dialog"] {padding-top:30px;}
.normal_form[form-role="dialog"] .row .field_text {width:150px;}
.normal_form[form-role="dialog"] .input-text{width:220px;}
</style>
<form name="dialogform" class="normal_form" form-role="dialog" onsubmit="return Core.Sys.Dialogform(this);" autocomplete="off">
    <div class="row">
        <div class="field_text require">结算日期：</div>
        <input type="text" class="input-text require" name="sday" value="{$sday ?? ''}" disabled />
    </div>
    <div class="row">
        <div class="field_text">当日代收金额：</div>
        <input type="text" class="input-text require" name="dayrcvd" value="{$dayrcvd ?? ''}" maxlength="200" disabled  /> <span style="color: gray;">元，{if ($res['id'] ?? 0)}记录：{$res['dayrcvd'] ?? 0} 元{/if}</span>
    </div>
    <div class="row">
        <div class="field_text">当日结算金额：</div>
        <input type="text" class="input-text require" name="daypayt" value="{$res['daypayt'] ?? ''}" maxlength="200" placeholder="请输入当日付门店金额" /> <span style="color: gray;">元</span>
    </div>
    <div class="row">
        <div class="field_text">当日剩余未结算金额：</div>
        <input type="text" class="input-text require" name="dayuid" value="{$res['dayuid'] ?? ''}" maxlength="200" placeholder="请输入当日剩余未结算金额" /> <span style="color: gray;">元</span>
    </div>
    <div class="row">
        <div class="field_text">当日是否结清：</div>
        <div class="labelrow">
            <label class="l-checkbox"><input type="checkbox" name="settled" value="1" {if ($res['settled'] ?? 0)} checked{/if} /><i></i><span>是</span></label>
        </div>
    </div>
    <div class="row">
        <div class="field_text">结算备注信息：</div>
        <input type="text" class="input-text" name="desc" value="{$res['desc'] ?? ''}" maxlength="100" placeholder="请输入结算备注信息" style="width:350px;" />
    </div>
    <div class="row form-footer-bar">
        <p class="colortip"></p>
        <button class="btn" role="btn-cancel">取消</button>
        <button class="btn btn-primary" type="submit" role="btn-submit">保存</button>
    </div>
</form>
<script type="text/javascript">
Core.Sys.Dialogform = function(form){
    var form = $(form);
    var p    = {
        'sday'    : form.find(":text[name='sday']").val(),
        'dayrcvd' : form.find(":text[name='dayrcvd']").val(),
        'daypayt' : form.find(":text[name='daypayt']").val(),
        'dayuid'  : form.find(":text[name='dayuid']").val(),
        'desc'    : form.find(":text[name='desc']").val(),
        'settled' : 0,
	}
    form.find("p.colortip").html('');
    
    if (!Core.rule('datetime',p['sday'])){
        form.find("p.colortip").html('结算日期错误!');return false;
    }
    if (!Core.rule('money',p['daypayt'])){
		form.find("p.colortip").html('请输入当日结算金额!');return false;
	}
    if (!Core.rule('money',p['dayuid'])){
        form.find("p.colortip").html('请输入正确的当日剩余未结算金额!');return false;
    }
    if ($(':checkbox[name="settled"][value="1"]').prop("checked")) {
        p['settled'] = 1;
    }

	form.find(":button").attr('disabled','disabled');
	$.ajax({type : "POST",dataType: "json",cache : false, url : "{$_G['_mc_']}/edit/channel/{$channel ?? 0}/sday/{$sday ?? ''}?r="+Math.random(),data : p,success: function(data){
	   try{
		   if (data['state'] == 'y'){
                $('#datalist').datagrid('reload');$(form).dialogClose();
		   } else {
                form.find(":button").removeAttr('disabled');form.find("p.colortip").html(data['msg']);return false;
		   }
	   }catch(e){form.find(":button").removeAttr('disabled');form.find("p.colortip").html('数据提交失败!');return false;}
	}});
	return false;
}
$(function(){
    Core.easyloaderInit();
    $('.oselectregion').oselect([{
        type: 'easyui',
        url: "/index.ajax/district/level/1",
        fieldv: 'id',
        fieldt: 'name',
        filter: function(result) {
            return result['rows'];
        }
    },{
        type: 'easyui',
         url: "/index.ajax/district/level/2/pid/@parentValue",
        fieldv: 'id',
        fieldt: 'name',
        filter: function(result) {
            return result['rows'];
        }
    },{
        type: 'easyui',
         url: "/index.ajax/district/level/3/pid/@parentValue",
        fieldv: 'id',
        fieldt: 'name',
        filter: function(result) {
            return result['rows'];
        }
    }], function (event, elem, id, txt) {
        // console.log('oselectseries:', id, '|', txt);
    });
});
</script>